//
//  ImageButtonView.m
//  FreeReading
//
//  Created by lanou3g on 15/10/28.
//  Copyright © 2015年 lanou3g. All rights reserved.
//

#import "ImageButtonView.h"
#import "ImageButton.h"

@implementation ImageButtonView

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self addSubviews];
        
    }
    return self;
}

- (void)addSubviews
{
    NSArray *imageNameArray = @[@"guide_tag_103", @"guide_tag_67", @"guide_tag_48", @"guide_tag_102", @"guide_tag_49"];
    NSArray *titleArray = @[@"演艺", @"度假", @"电影", @"美食", @"活动"];
    for (int i = 0; i < 5; i++) {
        
        ImageButton *button = [ImageButton buttonWithType:UIButtonTypeCustom];
        button.frame = CGRectMake((kScreenWidth / 5 - 40) / 2 + kScreenWidth / 5 * i, kMargin / 2 + 2, 40, 40);
        button.index = i;
        [button setBackgroundImage:[UIImage imageNamed:imageNameArray[i]] forState:UIControlStateNormal];
        [self addSubview:button];
        
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake((kScreenWidth / 5 - 40) / 2 + kScreenWidth / 5 * i, button.maxY + 5, 40, 20)];
        label.font = [UIFont systemFontOfSize:14];
        label.textAlignment = NSTextAlignmentCenter;
        label.text = titleArray[i];
        [self addSubview:label];
    }
    
}

@end
